Socket
Socket
Sign inDemoInstall

array-from

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-from

A ponyfill for the ES 2015 (ES6) `Array.from()`.


Version published
Maintainers
1
Created

What is array-from?

The npm package 'array-from' provides a utility function for creating arrays from array-like or iterable objects. This is particularly useful for converting objects that resemble arrays but do not have the full functionality of an Array, such as NodeLists or arguments objects, into true JavaScript arrays.

What are array-from's main functionalities?

Creating arrays from array-like objects

Converts an array-like object (object with properties indexed from 0 and a length property) into a true array.

const arrayFrom = require('array-from');
const arrayLike = {0: 'hello', 1: 'world', length: 2};
const newArray = arrayFrom(arrayLike);
console.log(newArray); // ['hello', 'world']

Creating arrays from iterable objects

Converts an iterable object (like Set or Map) into a true array, allowing for easier manipulation and access to array methods.

const arrayFrom = require('array-from');
const set = new Set(['foo', 'bar', 'baz']);
const newArray = arrayFrom(set);
console.log(newArray); // ['foo', 'bar', 'baz']

Other packages similar to array-from

Keywords

FAQs

Package last updated on 28 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc